<template>
  <div>
    <div class="box">
      <img src="../assets/登录页-1.jpg" alt="" />
    </div>
      <van-form @submit="onSubmit">
        <van-field v-model="username" name="用户名" label="账户" />
        <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
        />
        <div style="margin: 16px">
          <van-button round block type="info" native-type="submit"
            >立即登录</van-button
          >
        </div>
      </van-form>
  </div>
</template>

<script>
import {GetLogon} from "@/request/api"
export default {
  data() {
    return {
   
      username: '',
      password: '',
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
      let username=values["用户名"]
      let password=values["密码"]
      GetLogon({
        username,
        password
      }).then(res=>{
        if(res.errCode=="0"){
             console.log(res);
           this.$toast.success("登录成功")
           setTimeout(()=>{
              localStorage.setItem("token",res.data)
              this.$router.push("/home")
           })
          
        }
        
      })

    },
  },
 
};
</script>
 
<style lang = "less" scoped>
.box{
  img{
    width: 100%;
  }
}
</style>